package test04.sync.test07.sisuo.b;

/**
 * @Author zqx
 * @Date 2024-03-21
 */
public class TwoThread extends Thread{

    public static final Object twoLock = new Object();

    @Override
    public void run() {
        synchronized (twoLock) {
            System.out.println("TwoThread-获得了twoLock这把锁，做一些相关的处理...");

            // 当前线程睡眠1秒 - 抱着 twoLock 这个锁进入阻塞状态
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            synchronized (OneThread.oneLock) {
                System.out.println("TwoThread-获得了oneLock这把锁，做一些相关的处理...");
            }
        }
    }
}
